﻿<UserControl x:Class="Modules.Login.Views.LoginView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:commands="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
             xmlns:controls="clr-namespace:Common.Controls.Controls;assembly=Common.Controls"
             xmlns:extCommands="clr-namespace:Common.Commands;assembly=Common.Commands"
             mc:Ignorable="d">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Common.Dialogs;component/Styles/CommonStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <Border BorderThickness="2" CornerRadius="8" BorderBrush="Black" Background="LightGray" HorizontalAlignment="Center" VerticalAlignment="Center">
        <Grid x:Name="LayoutRoot" Width="300" Height="150" 
              controls:BusyIndicatorBehavior.AddMargins="True" 
              controls:BusyIndicatorBehavior.BusyState="{Binding IsBusy}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            
            <TextBlock Text="User:" FontWeight="Bold" Grid.Row="0" Grid.Column="0" Margin="12,0,12,0"
                       HorizontalAlignment="Left" VerticalAlignment="Center"/>
            
            <TextBox x:Name="UserNameTextBox" Grid.Column="1" Margin="12,0" VerticalAlignment="Center"
                     PreviewKeyDown="UserNameTextBox_PreviewKeyDown"
                     Text="{Binding UserName,UpdateSourceTrigger=PropertyChanged}"
                     />
            
            <TextBlock Text="Password:" FontWeight="Bold" Grid.Row="1" Grid.Column="0" Margin="12,0,12,0"
                       HorizontalAlignment="Left" VerticalAlignment="Center"/>

            <PasswordBox x:Name="PasswordBox" Grid.Row="1" Grid.Column="1" Margin="12,0" VerticalAlignment="Center"
                     PreviewKeyDown="PasswordBox_PreviewKeyDown"
                     extCommands:KeyUp.Command="{Binding KeyUpCommand}"
                     />

            <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right">
                <Label Content="Create new account" Cursor="Hand" Foreground="Blue"
                       VerticalAlignment="Center"
                       extCommands:MouseDown.Command="{Binding RegisterNewUserCommand}"
                       />
                <Button x:Name="LoginButton" Content="Ok" Height="24" Width="75" Margin="12,0"
                        Style="{StaticResource DialogButtonStyle}"
                        commands:Click.Command="{Binding LoginCommand}"
                        />
            </StackPanel>
        </Grid>
    </Border>
</UserControl>
